package com.sxy;

import com.sxy.dao.BookDao;
import com.sxy.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class App2 {
    public static void main(String[] args) {
        //3.获取ioc容器
        ApplicationContext c = new ClassPathXmlApplicationContext("applicationContext.xml");
        //4.获取bean
//        BookDao bookDao = (BookDao) c.getBean("bookDao");
//
//        bookDao.save();
        //spring调用bean创建对象时是使用的反射来调用无参构造方法
        BookService bookService = (BookService) c.getBean("service");
        BookService bookService1 = (BookService) c.getBean("service");
        System.out.println(bookService);
        System.out.println(bookService1);
        bookService.save();
    }
}
